home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / bathints.zip / BH_02.DOC < prev    next >
Text File  |  1987-10-26  |  4KB  |  101 lines

  1.  
  2.                                   BAT-HINT # 2
  3.  
  4. **************************************************************************
  5.  
  6. from the BATHINTS library... part of the BATPOWER CONFERENCE from:
  7.  
  8.                          THE PAINFRAME OPUS/FIDO 261/1004
  9.  
  10.                         Baltimore, Maryland 1-301-488-7461
  11.  
  12. **************************************************************************
  13.  
  14.                            The ECHO and REM commands
  15.  
  16. The ECHO command has several interesting features and performs in a
  17. specific manner under a variety of conditions:
  18.  
  19.     1.  The ECHO command is normally used to inhibit the display of
  20.         batch file command lines. Most batch files start with the command:
  21.  
  22.         ECHO OFF
  23.  
  24.         The same command isuued at the DOS prompt will also inhibit the
  25.         display of the DOS prompt.
  26.  
  27.     2.  If a batch file is called from another batch file when ECHO was off
  28.         in the first batch file, ECHO will also be turned off in the second
  29.         batch file, unless the second batch file is called as a string
  30.         after loading another command processor (see BAT-HINT #1 for an
  31.         explanation of secondary command processors). For example, in the
  32.         first two examples shown below, echo will automatically be off
  33.         in the second batch file:
  34.  
  35.         FIRST.BAT                      SECOND.BAT
  36.  
  37.         echo off                       ....
  38.         ....                           ....
  39.         ....                           ....
  40.         ....
  41.         second
  42.  
  43.         In the following two examples, ECHO will be on in the second batch
  44.         file:
  45.  
  46.         FIRST.BAT                      SECOND.BAT
  47.  
  48.         echo off                       ....
  49.         ....                           ....
  50.         ....                           ....
  51.         ....
  52.         command /c second
  53.         ....
  54.         ....
  55.  
  56.         where .... is meant to represent any other command on a line.
  57.  
  58.     3.  When ECHO is off, remarks entered after the PAUSE command are not
  59.         displayed. When ECHO is on, the PAUSE command may be followed by a
  60.         remark that will be diplayed on the monitor (along with the word
  61.         pause!).
  62.  
  63. The REM command in DOS is very simple. It simply displays a remark entered
  64. after the REM command. If ECHO is on, the remark (and the word REM!) are
  65. displayed. If echo is off, neither the remark nor the REM command are
  66. displayed. It is useful for including explanatory remarks in batch files.
  67. Remarks can be entered in another way however. Since DOS does not display
  68. batch file command lines starting with a colon (:), preceeding a command
  69. line or a remark will inhibit the display and execution of that command
  70. line. Normally the colon is used to identify a batch file label. However,
  71. the colon can be of great use in the development of batch files and for
  72. troubleshooting the execution of batch files. For example, if the bat file
  73. shown below (sample.bat) was used to load several memory resident programs
  74. (memres1, memres2, memres3) and a problem was encountered when trying to
  75. perform some other function, the command lines in question could be hidden
  76. from execution by inserting a colon in front of the command line. The
  77. system could then be rebooted and the bat file run with one line hidden to
  78. test the effect of loading that memres program (memres2 in sample.bat shown
  79. below). Using the colon in this manner, one need only remove the colon,
  80. rather than retyping the command line over again, to restore the bat file
  81. to its original sequence of commands.
  82.  
  83.      SAMPLE.BAT
  84.  
  85.      echo off
  86.      cd\memprog
  87.      memres1
  88.      :memres2
  89.      memres3
  90.      cd\
  91.  
  92. Beware however that if the bat file in question contains sveral goto
  93. commands and :labels, the inclusion of unreferenced labels in this manner
  94. will slow the execution of the batch file. Furthermore, care should be
  95. taken to avoid a conflict between the first eight letters of referenced
  96. labels and the first eight letters of command lines hidden with a colon
  97. (unreferenced labels). Users of DOS 2.X should use a single period (.)
  98. rather than a colon, in the example shown above.
  99.  
  100. ******************************************************* David Creasey
  101.